package com.dong;

import redis.clients.jedis.Jedis;

public class TestList {
    public static void main(String[] args) {
        Jedis jedis = new Jedis("127.0.0.1", 6379);
        jedis.flushDB();
        System.out.println("========添加一个list===========");
        jedis.lpush("col","arraylist","vector","stack","hashmap","weakhashmap","linkset");
        jedis.lpush("col","hashset");
        jedis.lpush("col","treeset");
        jedis.lpush("col","treemap");
        System.out.println("col的内容:"+jedis.lrange("col",0,-1));
        System.out.println("col区间0-3的元素:"+jedis.lrange("col",0,3));
        System.out.println("========================");
        System.out.println("删除指定元素个数:"+jedis.lrem("col",2,"hashmap"));
        System.out.println("col的内容:"+jedis.lrange("col",0,-1));
        System.out.println("删除下表0-3的元素:"+jedis.ltrim("col",0,3));
        System.out.println("col的内容:"+jedis.lrange("col",0,-1));
        System.out.println("col列表出栈(左端):"+jedis.lpop("col"));
        System.out.println("col的内容:"+jedis.lrange("col",0,-1));
        System.out.println("col添加元素，从列表右端,与lpush相对应:"+jedis.rpush("col","lindongsong"));
        System.out.println("col的内容:"+jedis.lrange("col",0,-1));
        System.out.println("col列表出栈(右端)"+ jedis.rpop("col"));
        System.out.println("col的内容:"+jedis.lrange("col",0,-1));
        System.out.println("修改col指定下标1的内容:"+jedis.lset("col",1,"lin"));
        System.out.println("col的内容:"+jedis.lrange("col",0,-1));
        System.out.println("=================================");
        System.out.println("col的长度:"+jedis.llen("col"));
        System.out.println("获取col下标为2的元素:"+jedis.lindex("col",2));
        System.out.println("================================");
        jedis.lpush("sort","3","6","2","0","7","4");
        System.out.println("sort排序前:"+jedis.lrange("sort",0,-1));
        System.out.println(jedis.sort("sort"));
        System.out.println("sort排序后:"+jedis.lrange("sort",0,-1));



    }

}
